import java.util.Stack;
import java.util.EmptyStackException;

public class wxudong{

    public static void main(String[] args) {
        
        StackQueue so = new StackQueue();
        so.push(1);
        so.push(2);
        so.push(3);
        so.pop();
        so.pop();
		so.peek();
        so.push(4);
        so.pop();
        so.push(5);
        so.pop();
        so.pop();
    }

}

class StackQueue{
    private Stack<Integer> stackIn = new Stack<Integer>();
    private Stack<Integer> stackOut = new Stack<Integer>();

    public void push(int node) {
		stackIn.push(node);
		System.out.println("push = " + node);
    }

    public int pop() {
    	if(stackOut.isEmpty()) {
            while (!stackIn.empty()) {
                stackOut.push(stackIn.pop());
            }
        }
        int node = stackOut.pop();
        System.out.println("pop = " + node);
        return node;
    }
	
    public int peek() {
    	if(stackOut.isEmpty()) {
    		while (!stackIn.empty()) {
                stackOut.push(stackIn.pop());
            }
    	}
    	int node = stackOut.peek();
    	System.out.println("peek = " + node);
    	return node;
    }

    public boolean empty() {
    	return stackIn.empty() && stackOut.empty();
    }
}
